import {
  addComponent,
  defineNuxtModule,
  addComponentsDir,
  addImports,
  addImportsSources,
  addPlugin,
  createResolver,
} from '@nuxt/kit'
// import webTypes from 'naive-ui/web-types.json';
export default defineNuxtModule({
  setup() {
    // const names = webTypes.contributions.html['vue-components'].map(
    //   ({ name }) => name,
    // );
    // // console.log('🚀 ~ setup ~ names:', names);

    // names.forEach((name) => {
    //   addComponent({
    //     name,
    //     export: name,
    //     filePath: `naive-ui`,
    //   });
    // });

    // addImportsSources({
    //   from: 'naive-ui',
    //   imports: ['useMessage', 'useDialog', 'useNotification', 'useLoadingBar'],
    // });

    const resolver = createResolver(import.meta.url)
    addPlugin({
      src: resolver.resolve('runtime/plugin'),
      // mode: 'client',
    })
    addImports({
      name: 'useIFetch',
      as: 'useIFetch',
      from: resolver.resolve('runtime/useIFetch'),
    })
    // addComponentsDir({
    //   path: '~/node_modules/naive-ui/es',
    //   pathPrefix: false,
    //   prefix: 'N',
    //   pattern: ['*/index.mjs'],
    // });
  },
})
